#ifndef _MIXP_MODULE_H
#define _MIXP_MODULE_H

#include "mixedprocess.h"
#include "json/cJSON.h"

#ifdef __cplusplus
extern "C"
{
#endif
    struct mixp_module;

    typedef enum mixp_module_type
    {
        MIXP_MODULE_AUDIO_DECODE = 0,
        MIXP_MODULE_VAD,
        MIXP_MODULE_POST,
    } mixp_module_type_t;

    typedef struct mixp_module_ops
    {
        void *res;
        void *ins;

        struct mixp_module_ops *(*load)(struct mixp_module *, cJSON *);
        struct mixp_module_ops *(*create)(void *);

        int (*start)(struct mixp_module_ops *, void *);
        int (*feed)(struct mixp_module_ops *, void *);
        int (*stop)(struct mixp_module_ops *, void *);

        void (*destroy)(struct mixp_module_ops *);
        void (*unload)(struct mixp_module_ops *);
    } mixp_module_ops_t;

    typedef struct mixp_module
    {
        mixp_module_type_t module_type;

        mixp_uint_t n_max_workers;
        mixp_uint_t n_workers;
        mixp_uint_t n_threads;

        char *name;
        char *path;
        void *handle;

        struct list_head entry;
        const mixp_module_ops_t *ops;
    } mixp_module_t;

    void mixp_module_free(mixp_module_t *);
    const mixp_module_ops_t *module_ops_by_type(mixp_module_type_t);

#ifdef __cplusplus
};
#endif
#endif